<template>
  <div class="forum">
    <div class="forum_breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>当前位置</el-breadcrumb-item>
        <el-breadcrumb-item>首页</el-breadcrumb-item>
        <el-breadcrumb-item>学科论坛</el-breadcrumb-item>
        <el-breadcrumb-item>{{ routerName }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="forum_section">
      <div class="forum_list">
        <div class="children_first">{{ jsondata.label }}</div>
        <div
          :class="
            routerName === item.label ? 'is_children_list' : 'children_list'
          "
          @click="handleClick(item)"
          v-for="(item, index) in topicList"
          :key="index"
        >
          {{ item.label }}
        </div>
      </div>
      <div class="roter_view">
        <router-view :topicType="topicType"></router-view>
      </div>
    </div>
  </div>
</template>

<script>
import topicList from "@/utils/topicList.js";
export default {
  name: "index",
  data() {
    return {
      routerName: "",
      topicList,
      jsondata: {
        label: "学科论坛",
        children: [
          {
            label: "文章列表",
            url: "/forum/article",
          },
        ],
      },
      topicType: "",
    };
  },
  created() {
    this.routerName = this.$route.query.routerName;
  },

  methods: {
    handleClick(val) {
      this.routerName = val.value || null;
      const routeData = {
        path: "/forum/article",
      };
      if (val.value) {
        routeData.query = {
          type: val.value,
        };
      }
      this.$router.push(routeData);
    },
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.forum {
  width: 1280px;
  margin: 0 auto;

  .forum_breadcrumb {
    padding: 20px;
    padding-left: 0;
  }

  .forum_section {
    display: flex;
    justify-content: space-between;

    .forum_list {
      text-align: center;
      font-weight: bold;

      .children_first {
        width: 200px;
        height: 56px;
        line-height: 56px;
        border: 1px solid #f1f1f1;
        background: #f1f1f1;
        color: #0a7b19;
      }

      .children_list {
        width: 200px;
        height: 56px;
        line-height: 56px;
        background: #ffffff;
        border: 1px solid #f1f1f1;
        cursor: pointer;
        &:hover {
          color: #0a7b19;
          background: #f4fff6;
        }
      }
      .is_children_list {
        width: 200px;
        height: 56px;
        line-height: 56px;
        color: #0a7b19;
        background: #f4fff6;
        border-bottom: 1px solid #f1f1f1;
        cursor: pointer;
      }
    }
  }

  .roter_view {
    width: 1060px;
  }
}
</style>
